<template>
    <div class="title-bar">
        <div class="row body">
            <!-- 返回按钮 -->
            <div class="left btn-back" @click="onPageBack">
                <img
                    src="https://7769-winfyho-cloud-0gfbcdsg0e062644-1301825810.tcb.qcloud.la/cloudbase-cms/upload/2021-04-30/olp1bnl2ah9ovfvibrxscgg1xv6ynnut_.png"
                />
            </div>

            <!-- 中间区域 -->
            <div v-if="title" class="nav-center">{{ title }}</div>

            <!-- 右边区域 -->
            <div class="nav-right">
                <slot name="right"></slot>
            </div>
        </div>
    </div>
</template>

<script>
export default {
    props: {
        title: {
            type: String
        }
    },
    data() {
        return {};
    },

    methods: {
        onPageBack() {
            this.$router.go(-1);
        }
    }
};
</script>


<style lang="less" scoped>
.title-bar {
    position: fixed;
    z-index: 1000;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    height: 90px;

    .body {
        box-sizing: border-box;
        height: 100%;
        padding: 20px 0;
        justify-content: space-between;
        align-items: center;
        background: #fff;
        .left {
            z-index: 2;
            position: absolute;
            left: 30px;
            width: 40px;
            height: 40px;
        }

        .nav-center {
            z-index: 1;
            position: absolute;
            width: 100%;
            text-align: center;
        }

        .nav-right {
            z-index: 2;
            position: absolute;
            right: 30px;
        }
    }

    .body-light {
        background: #fff;
    }

    .body-dark {
        background: #333;
    }
}
</style>